'use strict'
const path = require('path')
const webpack = require('webpack')
const CompressionWebpackPlugin = require('compression-webpack-plugin');

function resolve(dir) {
  return path.join(__dirname, dir)
}

// All configuration item explanations can be find in https://cli.vuejs.org/config/
module.exports = {
  publicPath: './',
  outputDir: 'dist',
  assetsDir: 'static',
  // lintOnSave: process.env.NODE_ENV === 'development',
  lintOnSave: false,
  productionSourceMap: false,
  devServer: {
    host: '0.0.0.0',
    port: 8099,
    open: true,
    overlay: {
      warnings: false,
      errors: true
    },
    proxy: {
      '/app': {
        target: process.env.VUE_APP_BASE_API,
        changeOrigin: true,
        pathRewrite: {
          '^/app': 'app'
        }
      }
    }
  },
  configureWebpack: config => {
    if (process.env.NODE_ENV === 'production') {
      return false;
      let settings = {};
      settings = {
        plugins: [
          // 忽略mockjs不打包
          new webpack.IgnorePlugin({
            resourceRegExp: /index.js/,
            contextRegExp: /mock/
          }),

          new CompressionWebpackPlugin({
            filename: '[path].gz[query]',
            algorithm: 'gzip',
            test: new RegExp('\\.(' + ['js', 'css'].join('|') + ')$'),//匹配文件名
            threshold: 10240,//对10K以上的数据进行压缩
            minRatio: 0.8,
            deleteOriginalAssets:false,//是否删除源文件
          })
        ],
        externals: {
          /**
           *key: main.js中全局引入的路径
           *value: 全局暴露出来的对象名
           */
          // "cesium/Cesium": "Cesium" //忽略js
          // "cesium/Widgets/widgets.css": "Widgets" //忽略css
        }
      }
      return settings;
    }
  },
  chainWebpack: config => {
    // 链式配置
  },
  css: {
    // css预设器配置项
    
  }
}
